import React, { PureComponent }from 'react';
import PropTypes from 'prop-types';
import { Route, withRouter } from 'dva/router';
import { Button, Icon } from 'antd';

import { AddHoliday, HolidayMenu } from "./holiday";
import { AddFood, FoodMenu} from "./food";
import styles from './operator.less'

class Operator extends PureComponent {
 renderHoliday = () => {
    const { history, onSelectDate } = this.props;
    return(
      <div className={styles.wrapper}>
        <header className={styles.title}>
          <span>请假</span>
          <span style={{float: 'right', cursor: 'pointer'}}>
            <Icon onClick={ () => {history.push('/holiday/add')} } style={{ marginRight: '10px' }} type="plus" theme="outlined" />
            <Icon onClick={ () => {history.push('/holiday/menu')} } type="user" theme="outlined" />
          </span>
        </header>
        <div className={styles.content}>
          <Route path='/holiday/add'  exact render={() => {return (<AddHoliday history={history} onSelectDate={onSelectDate}/>)}}/>
          <Route path='/holiday/menu' exact component={HolidayMenu}/>
        </div>
      </div>
    )
 };
  renderBookFood = () => {
    const { history, onSelectDate } = this.props;
    return(
      <div><div className={styles.wrapper}>
        <header className={styles.title}>
          <span>报餐</span>
          <span style={{float: 'right', cursor: 'pointer'}}>
            <Icon onClick={ () => {history.push('/bookfood/add')} } style={{ marginRight: '10px' }} type="plus" theme="outlined" />
            <Icon onClick={ () => {history.push('/bookfood/menu')} } type="user" theme="outlined" />
          </span>
        </header>
        <div className={styles.content}>
          <Route path='/bookfood/add'  exact render={() => {return (<AddFood history={history} onSelectDate={onSelectDate}/>)}}/>
          <Route path='/bookfood/menu' exact component={FoodMenu}/>
        </div>
      </div></div>
    )
  }
  render() {
    return (
      <div>
        <Route path='/holiday' render={this.renderHoliday} />
        <Route path='/bookfood' render={this.renderBookFood} />
      </div>
    );
  }
}

export default withRouter(Operator)
